let express = require('express');
let webpackDevMiddleware = require('webpack-dev-middleware');//这才是一个真正中间件
let app = express();
let webpackConfig = require('./webpack.config');
let webpack = require('webpack');
//compiler代表整个编译对象
let compiler = webpack(webpackConfig);
/**
中间件里到底做了什么? compiler.run
1. 启动编译 compiler.run
2. 使用一个中间件，用来响应客户端对打包后的文件的请求
 */
app.use(webpackDevMiddleware(compiler,{}));
app.get('/users',function(req,res){
  res.json([{id:1,name:'zhufeng'}]);
});
app.listen(5000);